using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Bll;
using Entities;

public partial class checkoutcomplete : MyPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            IsMemberPage = true;
            IsDealerPage = true;

            ArrayList arr = (ArrayList) Session["Order"];
            OrderInfo orderInfo = (OrderInfo) arr[0] ;
            lblUsername.Text = username;
            lblOrderDate.Text = DateTime.Now.ToShortDateString();
            lblPerson.Text = orderInfo.ShipName;
            ShipInfo shipInfo = arr[1] as ShipInfo;
            lblShipVia.Text = shipInfo.ShipVia;
            lblShipAddress.Text = orderInfo.ShipAddress;
            lblShipCity.Text = orderInfo.ShipCity;
            lblShipPrice.Text = shipInfo.ShipPrice.ToString("C");
            AccountBll accBll = new AccountBll();
            AccountInfo accInfo = accBll.GetByUserName(username);
            decimal total = (decimal)HttpContext.Current.Session["Subtotal"];
            lblTotal.Text = total.ToString("C");
            lblDiscount.Text = accInfo.Discount.ToString() + "%";
            lblSubTotal.Text = orderInfo.SubTotal.ToString("C");            
            CartBll cart = (CartBll)Session["ShoppingCart"];
            LineItemInfo[] lines = cart.GetOrderLineItems();
            for (int i = 0; i < lines.Length; i++)
            {
                lblProductName.Text += lines[i].Name + "<br />";
                lblPrice.Text += lines[i].Price.ToString("C") + "<br />";
                lblQuantity.Text += lines[i].Quantity + "<br />";

            }
        }
    }
    protected override void OnUnload(EventArgs e)
    {
        HttpContext.Current.Session.Remove("ShoppingCart");
        HttpContext.Current.Session.Remove("Subtotal");
    }
}
